package top.ezzz.search.model;


import cn.hutool.json.JSONObject;

/**
 * @author noear
 * @since 1.2
 */
public class EsAliases {
    private final JSONObject obj;

    public EsAliases(JSONObject obj) {
        this.obj = obj;
    }

    public EsAliases add(String indiceName, String alias) {
        if (obj.get("add") == null) {
            obj.set("add", new JSONObject());
        }
        obj.getJSONObject("add").set("index", indiceName).set("alias", alias);
        return this;
    }

    public EsAliases remove(String indiceName, String alias) {
        if (obj.get("remove") == null) {
            obj.set("remove", new JSONObject());
        }
        obj.getJSONObject("remove").set("index", indiceName).set("alias", alias);
        return this;
    }
}
